using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.equip
{
[System.Serializable]
public  class TalentHole : HoleSetting
 {

    public System.Collections.Generic.List<cfg.equip.HoleAttrPromote> holePromote  = new System.Collections.Generic.List<cfg.equip.HoleAttrPromote>();
     


    public const int TYPE_ID = 1172827980;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(5);
        os.WriteSize(Tag.STRING | (1 << Tag.TAG_SHIFT));  os.WriteString(name);  
         os.WriteSize(Tag.STRING | (2 << Tag.TAG_SHIFT));  os.WriteString(holeIcon);  
         os.WriteSize(Tag.BEAN | (3 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_map_Vector2(holePos,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.INT | (4 << Tag.TAG_SHIFT));  os.WriteInt(costMaster);  
         os.WriteSize(Tag.LIST | (5 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_equip_HoleAttrPromote(holePromote,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.STRING | (1 << Tag.TAG_SHIFT)):   name = os.ReadString(); break;  
             case (Tag.STRING | (2 << Tag.TAG_SHIFT)):   holeIcon = os.ReadString(); break;  
             case (Tag.BEAN | (3 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); holePos = cfg.Extensions.unmarshal_compatible_cfg_map_Vector2(os); os = _oldOs; break; }   
             case (Tag.INT | (4 << Tag.TAG_SHIFT)):   costMaster = os.ReadInt(); break;  
             case (Tag.LIST | (5 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); holePromote = cfg.Extensions.unmarshal_compatible_list_cfg_equip_HoleAttrPromote(os); os = _oldOs; break; }   
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "TalentHole");
        ele.WriteStartElement("name"); ele.WriteAttributeString("id", "1"); ele.WriteString2(name); ele.WriteEndElement();
         ele.WriteStartElement("holeIcon"); ele.WriteAttributeString("id", "2"); ele.WriteString2(holeIcon); ele.WriteEndElement();
         ele.WriteStartElement("holePos"); ele.WriteAttributeString("id", "3"); cfg.Extensions.xml_marshal_cfg_map_Vector2(holePos,ele); ele.WriteEndElement();
         ele.WriteStartElement("costMaster"); ele.WriteAttributeString("id", "4"); ele.WriteInt(costMaster); ele.WriteEndElement();
         ele.WriteStartElement("holePromote"); ele.WriteAttributeString("id", "5"); cfg.Extensions.xml_marshal_list_cfg_equip_HoleAttrPromote(holePromote,ele); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  name = ele.ReadString2(); break; 
                 case 2:  holeIcon = ele.ReadString2(); break; 
                 case 3:  holePos = cfg.Extensions.xml_unmarshal_cfg_map_Vector2(ele); break; 
                 case 4:  costMaster = ele.ReadInt(); break; 
                 case 5:  holePromote = cfg.Extensions.xml_unmarshal_list_cfg_equip_HoleAttrPromote(ele); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "name":  name = ele.ReadString2(); break; 
                 case "hole_icon":  holeIcon = ele.ReadString2(); break; 
                 case "hole_pos":  holePos = cfg.Extensions.xml_unmarshal_cfg_map_Vector2(ele); break; 
                 case "cost_master":  costMaster = ele.ReadInt(); break; 
                 case "hole_promote":  holePromote = cfg.Extensions.xml_unmarshal_list_cfg_equip_HoleAttrPromote(ele); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
